package com.qk.my.wangtobesuper;

import com.qk.command.Command;
import com.qk.command.CommandFactory;
import com.qk.command.CommandFactory.CommandCode;
import com.qk.my.pojos.Player;
import com.qk.util.MyConsole;

/**
 * Hello world! .
 */
public class App {
	public static Player player = null;
	private static Command command;

	public static void main(String[] args) {

		MyConsole.println(" You are welcome to XUE BA!");
		MyConsole.println("Please command,you can input 'help' to get help");
		String info = null;
		int t = 0;
		while (true) {
			info = MyConsole.askUserInput("cmd");
			CommandCode cmd = null;
			try {
				cmd = CommandCode.valueOf(info.toUpperCase());
			} catch (IllegalArgumentException e1) {
				// TODO Auto-generated catch block
				t = 1;
				MyConsole.println("命令错误，请重新输入！");
				continue;

			}

			command = CommandFactory.buildFactory(player).buildCommand(cmd);

			try {
				command.execute();
			} catch (NullPointerException e) {
				// TODO Auto-generated catch block
				if (t == 0) {
					MyConsole.println("您还没有登录，无法使用该功能！");
				}
				t = 0;
			}

		}
	}
}
